// preload.js
const { contextBridge, ipcRenderer } = require('electron');

// 将ipcRenderer封装到一个全局变量中
contextBridge.exposeInMainWorld('eleMsg', {
    send: (channel, data) => {
        ipcRenderer.send(channel, data);
    },
    receive: (channel, func) => {
        ipcRenderer.on(channel, (event, ...args) => func(...args));
    }
});

//web页：eleMsg.send('message-to-index', 'Hello from the HTML page!');